package org.convallaria.system.biz.config;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.convallaria.system.biz.service.impl.SecurityConfigServiceImpl;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 安全配置初始化器
 * 在应用启动时初始化默认安全配置
 * 
 * @author convallaria
 * @since 1.0.0
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class SecurityConfigInitializer implements ApplicationRunner {

    private final SecurityConfigServiceImpl securityConfigService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        try {
            log.info("开始初始化安全配置...");
            securityConfigService.initializeDefaultConfigs();
            log.info("安全配置初始化完成");
        } catch (Exception e) {
            log.error("安全配置初始化失败", e);
        }
    }
}
